﻿<?php
    if($_GET['check']!="check"){
	$sel_u = mysql_query('SELECT teacher_to FROM users WHERE `username` = "'.$_SESSION['username'].'"');
	$row_u = mysql_fetch_assoc($sel_u);
	
	$select_m=mysql_query('SELECT * FROM user_articles WHERE tutorial = "'.$row_u['teacher_to'].'" ORDER BY date_added DESC');
	if(mysql_num_rows($select_m)>0){
	?>
	<table border="0" style="border-collapse: collapse; margin-left: 20px; width: 650px; text-shadow: 1px 1px 1px #fff;">
	<tr style='background-color: #b7b6b6;'><td style="width: 150px;" align="center"><p><b>Тема</b></p></td><td style="width: 70px;" align="center"><p><b>От</b></p></td><td style="width: 100px;" align="center"><p><b>Място</b></p></td><td style="width: 200px;" align="center"><p><b>Статия</b></p></td></tr>
	<tr><td></td></tr><tr><td></td></tr><tr><td></td></tr>
	<?php
	while($row_m=mysql_fetch_assoc($select_m)){
	$_GET['id'] = $row_m['article_id'];
	echo '<tr style="height: 40px; background-color: #ede7e7; text-shadow: 3px 3px 3px #fff;">
	<td style="padding-left: 10px;"><b>'.$row_m['article_name'].'</b></td><td style="text-align: center">'.$row_m['from_who'].'</td>
	<td style="text-align: center">'.$row_m['module'].'</td><td style="padding-right: 10px; text-align: center;">
	<a href="offered_articles.php?id='.$row_m['article_id'].'&amp;check='.check.'" class="message"><img src="../img/see.png" alt="see"/></a>
	<a href="offered_articles.php?id='.$row_m['article_id'].'&amp;check='.check.'&amp;mode=delete" class="message"><img src="../img/delete.png" alt="see"/></a>
	</td></tr><tr><td colspan="4" style="padding-left: 10px; padding-right: 10px;"><hr /></td></tr>';
	}
	?>
	</table>
	<?php
	}
	else{
	   echo "<p style='text-align: center; font-weight: bold;'>Няма предложени статии</p>";
	}
	}
	else {
	$select_m=mysql_query('SELECT * FROM user_articles WHERE `article_id`='.$_GET['id'].'');
    $row_m=mysql_fetch_assoc($select_m);
	?>
    <table border="0" style="border-collapse: collapse; margin-left: 20px; width: 650px; text-shadow: 1px 1px 1px #fff;">
      <tr style="background-color: #ede7e7;"><td align="right" style="width: 100px;"><p><b>Име</b></p></td><td align="left" style="padding-left: 20px;"><?php echo $row_m['article_name']; ?></td></tr>
	  <tr><td colspan="2"><hr /></td></tr>
	  <tr style="background-color: #ede7e7;"><td align="right"><p><b>Описание</b></p></td><td align="left" style="padding-left: 20px;"><?php echo $row_m['article_descr']; ?></td></tr>
	  <tr><td colspan="2"><hr /></td></tr>
	  <tr style="background-color: #ede7e7;"><td align="right"><p><b>От</b></p></td><td align="left" style="padding-left: 20px;"><?php echo $row_m['from_who']; ?></td></tr>
	  <tr><td colspan="2"><hr /></td></tr>
	  <tr style="background-color: #ede7e7;"><td align="right"><p><b>Самоучител</b></p></td><td align="left" style="padding-left: 20px;"><?php echo $row_m['tutorial']; ?></td></tr>
	  <tr><td colspan="2"><hr /></td></tr>
	  <tr style="background-color: #ede7e7;"><td align="right"><p><b>Раздел</b></p></td><td align="left" style="padding-left: 20px;"><?php echo $row_m['module']; ?></td></tr>
	  <tr><td colspan="2"><hr /></td></tr>
	  <tr style="background-color: #ede7e7;"><td align="right"><p><b>Изпратено</b></p></td><td align="left" style="padding-left: 20px;"><?php echo date('d-m-Y', $row_m['date_added']); ?></td></tr>
    </table>   
	<h3 style="text-align: center;">Статия</h3>
	<?php
	echo '<p style="margin-left: 25px;">'.$row_m['content'].'</p>';
	?>
	<form method="post" action="" class="form">
	   	  <p><input name="submit_faq" type="submit" value="Одобри статията" class="margin-left: 50px;"/>
	      <input type="hidden" name="article_name" value="<?php echo $row_m['article_name']; ?>"/>
		  <input type="hidden" name="article_descr" value="<?php echo $row_m['article_descr']; ?>"/>
		  <input type="hidden" name="content" value="'<?php echo $row_m['content']; ?>'"/>
		  <input type="hidden" name="date_added" value="<?php echo $row_m['date_added']; ?>"/>
		  <input type="hidden" name="place" value="<?php echo $row_m['module']; ?>"/>
		  <input type="hidden" name="tutorial" value="<?php echo $row_m['tutorial']; ?>"/>
		  <input type="hidden" name="from_who" value="<?php echo $row_m['from_who']; ?>"/>
		  <input type="hidden" name="hide1" value="57"/></p>
	</form>
	<?php
	include "../php/offered_articles.php";
	}
	?>